package projectionArea;

public class Solution {
    public int projectionArea(int[][] grid) {
        //投影面积
        int xy=0;
        int xz=0;
        int yz=0;
        for (int i = 0; i < grid.length; i++) {
            int maxj=0;
            int maxi=0;
            for (int j = 0; j < grid.length; j++) {
                if(grid[i][j]!=0){
                    xy++;
                }
                if(maxj<grid[i][j]){
                    maxj=grid[i][j];
                }
                if(maxi<grid[j][i]){
                    maxi=grid[j][i];
                }
            }
            xz+=maxj;
            yz+=maxi;
        }
        return xy+yz+xz;
    }
}
// xy平面
// xz ---- i

